package com.example.mqtt.common.filter;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2025/5/2 15:18
 **/
public class UserContext {
    private static final ThreadLocal<UserInfo> userHolder = new ThreadLocal<>();

    public static void setCurrentUser(UserInfo user) {
        userHolder.set(user);
    }

    public static UserInfo getCurrentUser() {
        return userHolder.get();
    }

    public static void clear() {
        userHolder.remove();
    }
}
